home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / lispref.info-5.z / lispref.info-5
Encoding:
GNU Info File  |  1998-05-21  |  47.7 KB  |  1,231 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo version
  2. 1.68 from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
  12. Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
  13. Reference Manual (for 19.15 and 20.1, 20.2) v3.2, April, May 1997
  14.  
  15.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  16. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  17. Copyright (C) 1995, 1996 Ben Wing.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that the
  25. entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Foundation.
  32.  
  33.    Permission is granted to copy and distribute modified versions of
  34. this manual under the conditions for verbatim copying, provided also
  35. that the section entitled "GNU General Public License" is included
  36. exactly as in the original, and provided that the entire resulting
  37. derived work is distributed under the terms of a permission notice
  38. identical to this one.
  39.  
  40.    Permission is granted to copy and distribute translations of this
  41. manual into another language, under the above conditions for modified
  42. versions, except that the section entitled "GNU General Public License"
  43. may be included in a translation approved by the Free Software
  44. Foundation instead of in the original English.
  45.  
  46. 
  47. File: lispref.info,  Node: String Basics,  Next: Predicates for Strings,  Up: Strings and Characters
  48.  
  49. String and Character Basics
  50. ===========================
  51.  
  52.    Strings in XEmacs Lisp are arrays that contain an ordered sequence of
  53. characters.  Characters are their own primitive object type in XEmacs
  54. 20.  However, in XEmacs 19, characters are represented in XEmacs Lisp as
  55. integers; whether an integer was intended as a character or not is
  56. determined only by how it is used.  *Note Character Type::.
  57.  
  58.    The length of a string (like any array) is fixed and independent of
  59. the string contents, and cannot be altered.  Strings in Lisp are *not*
  60. terminated by a distinguished character code.  (By contrast, strings in
  61. C are terminated by a character with ASCII code 0.)  This means that
  62. any character, including the null character (ASCII code 0), is a valid
  63. element of a string.
  64.  
  65.    Since strings are considered arrays, you can operate on them with the
  66. general array functions.  (*Note Sequences Arrays Vectors::.)  For
  67. example, you can access or change individual characters in a string
  68. using the functions `aref' and `aset' (*note Array Functions::.).
  69.  
  70.    Strings use an efficient representation for storing the characters
  71. in them, and thus take up much less memory than a vector of the same
  72. length.
  73.  
  74.    Sometimes you will see strings used to hold key sequences.  This
  75. exists for backward compatibility with Emacs 18, but should *not* be
  76. used in new code, since many key chords can't be represented at all and
  77. others (in particular meta key chords) are confused with accented
  78. characters.
  79.  
  80.    Strings are useful for holding regular expressions.  You can also
  81. match regular expressions against strings (*note Regexp Search::.).  The
  82. functions `match-string' (*note Simple Match Data::.) and
  83. `replace-match' (*note Replacing Match::.) are useful for decomposing
  84. and modifying strings based on regular expression matching.
  85.  
  86.    Like a buffer, a string can contain extents in it.  These extents are
  87. created when a function such as `buffer-substring' is called on a
  88. region with duplicable extents in it.  When the string is inserted into
  89. a buffer, the extents are inserted along with it.  *Note Duplicable
  90. Extents::.
  91.  
  92.    *Note Text::, for information about functions that display strings or
  93. copy them into buffers.  *Note Character Type::, and *Note String
  94. Type::, for information about the syntax of characters and strings.
  95.  
  96. 
  97. File: lispref.info,  Node: Predicates for Strings,  Next: Creating Strings,  Prev: String Basics,  Up: Strings and Characters
  98.  
  99. The Predicates for Strings
  100. ==========================
  101.  
  102.    For more information about general sequence and array predicates,
  103. see *Note Sequences Arrays Vectors::, and *Note Arrays::.
  104.  
  105.  - Function: stringp OBJECT
  106.      This function returns `t' if OBJECT is a string, `nil' otherwise.
  107.  
  108.  - Function: char-or-string-p OBJECT
  109.      This function returns `t' if OBJECT is a string or a character,
  110.      `nil' otherwise.
  111.  
  112. 
  113. File: lispref.info,  Node: Creating Strings,  Next: Predicates for Characters,  Prev: Predicates for Strings,  Up: Strings and Characters
  114.  
  115. Creating Strings
  116. ================
  117.  
  118.    The following functions create strings, either from scratch, or by
  119. putting strings together, or by taking them apart.
  120.  
  121.  - Function: make-string COUNT CHARACTER
  122.      This function returns a string made up of COUNT repetitions of
  123.      CHARACTER.  If COUNT is negative, an error is signaled.
  124.  
  125.           (make-string 5 ?x)
  126.                => "xxxxx"
  127.           (make-string 0 ?x)
  128.                => ""
  129.  
  130.      Other functions to compare with this one include `char-to-string'
  131.      (*note String Conversion::.), `make-vector' (*note Vectors::.), and
  132.      `make-list' (*note Building Lists::.).
  133.  
  134.  - Function: substring STRING START &optional END
  135.      This function returns a new string which consists of those
  136.      characters from STRING in the range from (and including) the
  137.      character at the index START up to (but excluding) the character
  138.      at the index END.  The first character is at index zero.
  139.  
  140.           (substring "abcdefg" 0 3)
  141.                => "abc"
  142.  
  143.      Here the index for `a' is 0, the index for `b' is 1, and the index
  144.      for `c' is 2.  Thus, three letters, `abc', are copied from the
  145.      string `"abcdefg"'.  The index 3 marks the character position up
  146.      to which the substring is copied.  The character whose index is 3
  147.      is actually the fourth character in the string.
  148.  
  149.      A negative number counts from the end of the string, so that -1
  150.      signifies the index of the last character of the string.  For
  151.      example:
  152.  
  153.           (substring "abcdefg" -3 -1)
  154.                => "ef"
  155.  
  156.      In this example, the index for `e' is -3, the index for `f' is -2,
  157.      and the index for `g' is -1.  Therefore, `e' and `f' are included,
  158.      and `g' is excluded.
  159.  
  160.      When `nil' is used as an index, it stands for the length of the
  161.      string.  Thus,
  162.  
  163.           (substring "abcdefg" -3 nil)
  164.                => "efg"
  165.  
  166.      Omitting the argument END is equivalent to specifying `nil'.  It
  167.      follows that `(substring STRING 0)' returns a copy of all of
  168.      STRING.
  169.  
  170.           (substring "abcdefg" 0)
  171.                => "abcdefg"
  172.  
  173.      But we recommend `copy-sequence' for this purpose (*note Sequence
  174.      Functions::.).
  175.  
  176.      If the characters copied from STRING have duplicable extents or
  177.      text properties, those are copied into the new string also.  *Note
  178.      Duplicable Extents::.
  179.  
  180.      A `wrong-type-argument' error is signaled if either START or END
  181.      is not an integer or `nil'.  An `args-out-of-range' error is
  182.      signaled if START indicates a character following END, or if
  183.      either integer is out of range for STRING.
  184.  
  185.      Contrast this function with `buffer-substring' (*note Buffer
  186.      Contents::.), which returns a string containing a portion of the
  187.      text in the current buffer.  The beginning of a string is at index
  188.      0, but the beginning of a buffer is at index 1.
  189.  
  190.  - Function: concat &rest SEQUENCES
  191.      This function returns a new string consisting of the characters in
  192.      the arguments passed to it (along with their text properties, if
  193.      any).  The arguments may be strings, lists of numbers, or vectors
  194.      of numbers; they are not themselves changed.  If `concat' receives
  195.      no arguments, it returns an empty string.
  196.  
  197.           (concat "abc" "-def")
  198.                => "abc-def"
  199.           (concat "abc" (list 120 (+ 256 121)) [122])
  200.                => "abcxyz"
  201.           ;; `nil' is an empty sequence.
  202.           (concat "abc" nil "-def")
  203.                => "abc-def"
  204.           (concat "The " "quick brown " "fox.")
  205.                => "The quick brown fox."
  206.           (concat)
  207.                => ""
  208.  
  209.      The second example above shows how characters stored in strings are
  210.      taken modulo 256.  In other words, each character in the string is
  211.      stored in one byte.
  212.  
  213.      The `concat' function always constructs a new string that is not
  214.      `eq' to any existing string.
  215.  
  216.      When an argument is an integer (not a sequence of integers), it is
  217.      converted to a string of digits making up the decimal printed
  218.      representation of the integer.  *Don't use this feature; we plan
  219.      to eliminate it.  If you already use this feature, change your
  220.      programs now!*  The proper way to convert an integer to a decimal
  221.      number in this way is with `format' (*note Formatting Strings::.)
  222.      or `number-to-string' (*note String Conversion::.).
  223.  
  224.           (concat 137)
  225.                => "137"
  226.           (concat 54 321)
  227.                => "54321"
  228.  
  229.      For information about other concatenation functions, see the
  230.      description of `mapconcat' in *Note Mapping Functions::, `vconcat'
  231.      in *Note Vectors::, `bvconcat' in *Note Bit Vectors::, and `append'
  232.      in *Note Building Lists::.
  233.  
  234. 
  235. File: lispref.info,  Node: Predicates for Characters,  Next: Character Codes,  Prev: Creating Strings,  Up: Strings and Characters
  236.  
  237. The Predicates for Characters
  238. =============================
  239.  
  240.  - Function: characterp OBJECT
  241.      This function returns `t' if OBJECT is a character.
  242.  
  243.      Some functions that work on integers (e.g. the comparison functions
  244.      <, <=, =, /=, etc. and the arithmetic functions +, -, *, etc.)
  245.      accept characters and implicitly convert them into integers.  In
  246.      general, functions that work on characters also accept char-ints
  247.      and implicitly convert them into characters.  WARNING: Neither of
  248.      these behaviors is very desirable, and they are maintained for
  249.      backward compatibility with old E-Lisp programs that confounded
  250.      characters and integers willy-nilly.  These behaviors may change
  251.      in the future; therefore, do not rely on them.  Instead, convert
  252.      the characters explicitly using `char-int'.
  253.  
  254.  - Function: integer-or-char-p OBJECT
  255.      This function returns `t' if OBJECT is an integer or character.
  256.  
  257. 
  258. File: lispref.info,  Node: Character Codes,  Next: Text Comparison,  Prev: Predicates for Characters,  Up: Strings and Characters
  259.  
  260. Character Codes
  261. ===============
  262.  
  263.  - Function: char-int CH
  264.      This function converts a character into an equivalent integer.
  265.      The resulting integer will always be non-negative.  The integers in
  266.      the range 0 - 255 map to characters as follows:
  267.  
  268.     0 - 31
  269.           Control set 0
  270.  
  271.     32 - 127
  272.           ASCII
  273.  
  274.     128 - 159
  275.           Control set 1
  276.  
  277.     160 - 255
  278.           Right half of ISO-8859-1
  279.  
  280.      If support for MULE does not exist, these are the only valid
  281.      character values.  When MULE support exists, the values assigned to
  282.      other characters may vary depending on the particular version of
  283.      XEmacs, the order in which character sets were loaded, etc., and
  284.      you should not depend on them.
  285.  
  286.  - Function: int-char INTEGER
  287.      This function converts an integer into the equivalent character.
  288.      Not all integers correspond to valid characters; use `char-int-p'
  289.      to determine whether this is the case.  If the integer cannot be
  290.      converted, `nil' is returned.
  291.  
  292.  - Function: char-int-p OBJECT
  293.      This function returns `t' if OBJECT is an integer that can be
  294.      converted into a character.
  295.  
  296.  - Function: char-or-char-int-p OBJECT
  297.      This function returns `t' if OBJECT is a character or an integer
  298.      that can be converted into one.
  299.  
  300. 
  301. File: lispref.info,  Node: Text Comparison,  Next: String Conversion,  Prev: Character Codes,  Up: Strings and Characters
  302.  
  303. Comparison of Characters and Strings
  304. ====================================
  305.  
  306.  - Function: char-equal CHARACTER1 CHARACTER2
  307.      This function returns `t' if the arguments represent the same
  308.      character, `nil' otherwise.  This function ignores differences in
  309.      case if `case-fold-search' is non-`nil'.
  310.  
  311.           (char-equal ?x ?x)
  312.                => t
  313.           (let ((case-fold-search t))
  314.             (char-equal ?x ?X))
  315.                => t
  316.           (let ((case-fold-search nil))
  317.             (char-equal ?x ?X))
  318.                => nil
  319.  
  320.  - Function: char= CHARACTER1 CHARACTER2
  321.      This function returns `t' if the arguments represent the same
  322.      character, `nil' otherwise.  Case is significant.
  323.  
  324.           (char= ?x ?x)
  325.                => t
  326.           (char= ?x ?X)
  327.                => nil
  328.           (let ((case-fold-search t))
  329.             (char-equal ?x ?X))
  330.                => nil
  331.           (let ((case-fold-search nil))
  332.             (char-equal ?x ?X))
  333.                => nil
  334.  
  335.  - Function: string= STRING1 STRING2
  336.      This function returns `t' if the characters of the two strings
  337.      match exactly; case is significant.
  338.  
  339.           (string= "abc" "abc")
  340.                => t
  341.           (string= "abc" "ABC")
  342.                => nil
  343.           (string= "ab" "ABC")
  344.                => nil
  345.  
  346.  
  347.  - Function: string-equal STRING1 STRING2
  348.      `string-equal' is another name for `string='.
  349.  
  350.  - Function: string< STRING1 STRING2
  351.      This function compares two strings a character at a time.  First it
  352.      scans both the strings at once to find the first pair of
  353.      corresponding characters that do not match.  If the lesser
  354.      character of those two is the character from STRING1, then STRING1
  355.      is less, and this function returns `t'.  If the lesser character
  356.      is the one from STRING2, then STRING1 is greater, and this
  357.      function returns `nil'.  If the two strings match entirely, the
  358.      value is `nil'.
  359.  
  360.      Pairs of characters are compared by their ASCII codes.  Keep in
  361.      mind that lower case letters have higher numeric values in the
  362.      ASCII character set than their upper case counterparts; numbers and
  363.      many punctuation characters have a lower numeric value than upper
  364.      case letters.
  365.  
  366.           (string< "abc" "abd")
  367.                => t
  368.           (string< "abd" "abc")
  369.                => nil
  370.           (string< "123" "abc")
  371.                => t
  372.  
  373.      When the strings have different lengths, and they match up to the
  374.      length of STRING1, then the result is `t'.  If they match up to
  375.      the length of STRING2, the result is `nil'.  A string of no
  376.      characters is less than any other string.
  377.  
  378.           (string< "" "abc")
  379.                => t
  380.           (string< "ab" "abc")
  381.                => t
  382.           (string< "abc" "")
  383.                => nil
  384.           (string< "abc" "ab")
  385.                => nil
  386.           (string< "" "")
  387.                => nil
  388.  
  389.  - Function: string-lessp STRING1 STRING2
  390.      `string-lessp' is another name for `string<'.
  391.  
  392.    See also `compare-buffer-substrings' in *Note Comparing Text::, for
  393. a way to compare text in buffers.  The function `string-match', which
  394. matches a regular expression against a string, can be used for a kind
  395. of string comparison; see *Note Regexp Search::.
  396.  
  397. 
  398. File: lispref.info,  Node: String Conversion,  Next: Modifying Strings,  Prev: Text Comparison,  Up: Strings and Characters
  399.  
  400. Conversion of Characters and Strings
  401. ====================================
  402.  
  403.    This section describes functions for conversions between characters,
  404. strings and integers.  `format' and `prin1-to-string' (*note Output
  405. Functions::.) can also convert Lisp objects into strings.
  406. `read-from-string' (*note Input Functions::.) can "convert" a string
  407. representation of a Lisp object into an object.
  408.  
  409.    *Note Documentation::, for functions that produce textual
  410. descriptions of text characters and general input events
  411. (`single-key-description' and `text-char-description').  These
  412. functions are used primarily for making help messages.
  413.  
  414.  - Function: char-to-string CHARACTER
  415.      This function returns a new string with a length of one character.
  416.      The value of CHARACTER, modulo 256, is used to initialize the
  417.      element of the string.
  418.  
  419.      This function is similar to `make-string' with an integer argument
  420.      of 1.  (*Note Creating Strings::.)  This conversion can also be
  421.      done with `format' using the `%c' format specification.  (*Note
  422.      Formatting Strings::.)
  423.  
  424.           (char-to-string ?x)
  425.                => "x"
  426.           (char-to-string (+ 256 ?x))
  427.                => "x"
  428.           (make-string 1 ?x)
  429.                => "x"
  430.  
  431.  - Function: string-to-char STRING
  432.      This function returns the first character in STRING.  If the
  433.      string is empty, the function returns 0. (Under XEmacs 19, the
  434.      value is also 0 when the first character of STRING is the null
  435.      character, ASCII code 0.)
  436.  
  437.           (string-to-char "ABC")
  438.                => ?A   ;; Under XEmacs 20.
  439.                => 65   ;; Under XEmacs 19.
  440.           (string-to-char "xyz")
  441.                => ?x   ;; Under XEmacs 20.
  442.                => 120  ;; Under XEmacs 19.
  443.           (string-to-char "")
  444.                => 0
  445.           (string-to-char "\000")
  446.                => ?\^ ;; Under XEmacs 20.
  447.                => 0    ;; Under XEmacs 20.
  448.  
  449.      This function may be eliminated in the future if it does not seem
  450.      useful enough to retain.
  451.  
  452.  - Function: number-to-string NUMBER
  453.      This function returns a string consisting of the printed
  454.      representation of NUMBER, which may be an integer or a floating
  455.      point number.  The value starts with a sign if the argument is
  456.      negative.
  457.  
  458.           (number-to-string 256)
  459.                => "256"
  460.           (number-to-string -23)
  461.                => "-23"
  462.           (number-to-string -23.5)
  463.                => "-23.5"
  464.  
  465.      `int-to-string' is a semi-obsolete alias for this function.
  466.  
  467.      See also the function `format' in *Note Formatting Strings::.
  468.  
  469.  - Function: string-to-number STRING
  470.      This function returns the numeric value of the characters in
  471.      STRING, read in base ten.  It skips spaces and tabs at the
  472.      beginning of STRING, then reads as much of STRING as it can
  473.      interpret as a number.  (On some systems it ignores other
  474.      whitespace at the beginning, not just spaces and tabs.)  If the
  475.      first character after the ignored whitespace is not a digit or a
  476.      minus sign, this function returns 0.
  477.  
  478.           (string-to-number "256")
  479.                => 256
  480.           (string-to-number "25 is a perfect square.")
  481.                => 25
  482.           (string-to-number "X256")
  483.                => 0
  484.           (string-to-number "-4.5")
  485.                => -4.5
  486.  
  487.      `string-to-int' is an obsolete alias for this function.
  488.  
  489. 
  490. File: lispref.info,  Node: Modifying Strings,  Next: String Properties,  Prev: String Conversion,  Up: Strings and Characters
  491.  
  492. Modifying Strings
  493. =================
  494.  
  495.    You can modify a string using the general array-modifying primitives.
  496. *Note Arrays::.  The function `aset' modifies a single character; the
  497. function `fillarray' sets all characters in the string to a specified
  498. character.
  499.  
  500.    Each string has a tick counter that starts out at zero (when the
  501. string is created) and is incremented each time a change is made to that
  502. string.
  503.  
  504.  - Function: string-modified-tick STRING
  505.      This function returns the tick counter for `string'.
  506.  
  507. 
  508. File: lispref.info,  Node: String Properties,  Next: Formatting Strings,  Prev: Modifying Strings,  Up: Strings and Characters
  509.  
  510. String Properties
  511. =================
  512.  
  513.    Similar to symbols, extents, faces, and glyphs, you can attach
  514. additional information to strings in the form of "string properties".
  515. These differ from text properties, which are logically attached to
  516. particular characters in the string.
  517.  
  518.    To attach a property to a string, use `put'.  To retrieve a property
  519. from a string, use `get'.  You can also use `remprop' to remove a
  520. property from a string and `object-props' to retrieve a list of all the
  521. properties in a string.
  522.  
  523. 
  524. File: lispref.info,  Node: Formatting Strings,  Next: Character Case,  Prev: String Properties,  Up: Strings and Characters
  525.  
  526. Formatting Strings
  527. ==================
  528.  
  529.    "Formatting" means constructing a string by substitution of computed
  530. values at various places in a constant string.  This string controls
  531. how the other values are printed as well as where they appear; it is
  532. called a "format string".
  533.  
  534.    Formatting is often useful for computing messages to be displayed.
  535. In fact, the functions `message' and `error' provide the same
  536. formatting feature described here; they differ from `format' only in
  537. how they use the result of formatting.
  538.  
  539.  - Function: format STRING &rest OBJECTS
  540.      This function returns a new string that is made by copying STRING
  541.      and then replacing any format specification in the copy with
  542.      encodings of the corresponding OBJECTS.  The arguments OBJECTS are
  543.      the computed values to be formatted.
  544.  
  545.    A format specification is a sequence of characters beginning with a
  546. `%'.  Thus, if there is a `%d' in STRING, the `format' function
  547. replaces it with the printed representation of one of the values to be
  548. formatted (one of the arguments OBJECTS).  For example:
  549.  
  550.      (format "The value of fill-column is %d." fill-column)
  551.           => "The value of fill-column is 72."
  552.  
  553.    If STRING contains more than one format specification, the format
  554. specifications correspond with successive values from OBJECTS.  Thus,
  555. the first format specification in STRING uses the first such value, the
  556. second format specification uses the second such value, and so on.  Any
  557. extra format specifications (those for which there are no corresponding
  558. values) cause unpredictable behavior.  Any extra values to be formatted
  559. are ignored.
  560.  
  561.    Certain format specifications require values of particular types.
  562. However, no error is signaled if the value actually supplied fails to
  563. have the expected type.  Instead, the output is likely to be
  564. meaningless.
  565.  
  566.    Here is a table of valid format specifications:
  567.  
  568. `%s'
  569.      Replace the specification with the printed representation of the
  570.      object, made without quoting.  Thus, strings are represented by
  571.      their contents alone, with no `"' characters, and symbols appear
  572.      without `\' characters.  This is equivalent to printing the object
  573.      with `princ'.
  574.  
  575.      If there is no corresponding object, the empty string is used.
  576.  
  577. `%S'
  578.      Replace the specification with the printed representation of the
  579.      object, made with quoting.  Thus, strings are enclosed in `"'
  580.      characters, and `\' characters appear where necessary before
  581.      special characters.  This is equivalent to printing the object
  582.      with `prin1'.
  583.  
  584.      If there is no corresponding object, the empty string is used.
  585.  
  586. `%o'
  587.      Replace the specification with the base-eight representation of an
  588.      integer.
  589.  
  590. `%d'
  591. `%i'
  592.      Replace the specification with the base-ten representation of an
  593.      integer.
  594.  
  595. `%x'
  596.      Replace the specification with the base-sixteen representation of
  597.      an integer, using lowercase letters.
  598.  
  599. `%X'
  600.      Replace the specification with the base-sixteen representation of
  601.      an integer, using uppercase letters.
  602.  
  603. `%c'
  604.      Replace the specification with the character which is the value
  605.      given.
  606.  
  607. `%e'
  608.      Replace the specification with the exponential notation for a
  609.      floating point number (e.g. `7.85200e+03').
  610.  
  611. `%f'
  612.      Replace the specification with the decimal-point notation for a
  613.      floating point number.
  614.  
  615. `%g'
  616.      Replace the specification with notation for a floating point
  617.      number, using a "pretty format".  Either exponential notation or
  618.      decimal-point notation will be used (usually whichever is
  619.      shorter), and trailing zeroes are removed from the fractional part.
  620.  
  621. `%%'
  622.      A single `%' is placed in the string.  This format specification is
  623.      unusual in that it does not use a value.  For example, `(format "%%
  624.      %d" 30)' returns `"% 30"'.
  625.  
  626.    Any other format character results in an `Invalid format operation'
  627. error.
  628.  
  629.    Here are several examples:
  630.  
  631.      (format "The name of this buffer is %s." (buffer-name))
  632.           => "The name of this buffer is strings.texi."
  633.      
  634.      (format "The buffer object prints as %s." (current-buffer))
  635.           => "The buffer object prints as #<buffer strings.texi>."
  636.      
  637.      (format "The octal value of %d is %o,
  638.               and the hex value is %x." 18 18 18)
  639.           => "The octal value of 18 is 22,
  640.               and the hex value is 12."
  641.  
  642.    There are many additional flags and specifications that can occur
  643. between the `%' and the format character, in the following order:
  644.  
  645.   1. An optional repositioning specification, which is a positive
  646.      integer followed by a `$'.
  647.  
  648.   2. Zero or more of the optional flag characters `-', `+', ` ', `0',
  649.      and `#'.
  650.  
  651.   3. An optional minimum field width.
  652.  
  653.   4. An optional precision, preceded by a `.' character.
  654.  
  655.    A "repositioning" specification changes which argument to `format'
  656. is used by the current and all following format specifications.
  657. Normally the first specification uses the first argument, the second
  658. specification uses the second argument, etc.  Using a repositioning
  659. specification, you can change this.  By placing a number N followed by
  660. a `$' between the `%' and the format character, you cause the
  661. specification to use the Nth argument.  The next specification will use
  662. the N+1'th argument, etc.
  663.  
  664.    For example:
  665.  
  666.      (format "Can't find file `%s' in directory `%s'."
  667.              "ignatius.c" "loyola/")
  668.           => "Can't find file `ignatius.c' in directory `loyola/'."
  669.      
  670.      (format "In directory `%2$s', the file `%1$s' was not found."
  671.              "ignatius.c" "loyola/")
  672.           => "In directory `loyola/', the file `ignatius.c' was not found."
  673.      
  674.      (format
  675.          "The numbers %d and %d are %1$x and %x in hex and %1$o and %o in octal."
  676.          37 12)
  677.      => "The numbers 37 and 12 are 25 and c in hex and 45 and 14 in octal."
  678.  
  679.    As you can see, this lets you reprocess arguments more than once or
  680. reword a format specification (thereby moving the arguments around)
  681. without having to actually reorder the arguments.  This is especially
  682. useful in translating messages from one language to another: Different
  683. languages use different word orders, and this sometimes entails changing
  684. the order of the arguments.  By using repositioning specifications,
  685. this can be accomplished without having to embed knowledge of particular
  686. languages into the location in the program's code where the message is
  687. displayed.
  688.  
  689.    All the specification characters allow an optional numeric prefix
  690. between the `%' and the character, and following any repositioning
  691. specification or flag.  The optional numeric prefix defines the minimum
  692. width for the object.  If the printed representation of the object
  693. contains fewer characters than this, then it is padded.  The padding is
  694. normally on the left, but will be on the right if the `-' flag
  695. character is given.  The padding character is normally a space, but if
  696. the `0' flag character is given, zeros are used for padding.
  697.  
  698.      (format "%06d is padded on the left with zeros" 123)
  699.           => "000123 is padded on the left with zeros"
  700.      
  701.      (format "%-6d is padded on the right" 123)
  702.           => "123    is padded on the right"
  703.  
  704.    `format' never truncates an object's printed representation, no
  705. matter what width you specify.  Thus, you can use a numeric prefix to
  706. specify a minimum spacing between columns with no risk of losing
  707. information.
  708.  
  709.    In the following three examples, `%7s' specifies a minimum width of
  710. 7.  In the first case, the string inserted in place of `%7s' has only 3
  711. letters, so 4 blank spaces are inserted for padding.  In the second
  712. case, the string `"specification"' is 13 letters wide but is not
  713. truncated.  In the third case, the padding is on the right.
  714.  
  715.      (format "The word `%7s' actually has %d letters in it."
  716.              "foo" (length "foo"))
  717.           => "The word `    foo' actually has 3 letters in it."
  718.  
  719.      (format "The word `%7s' actually has %d letters in it."
  720.              "specification" (length "specification"))
  721.           => "The word `specification' actually has 13 letters in it."
  722.  
  723.      (format "The word `%-7s' actually has %d letters in it."
  724.              "foo" (length "foo"))
  725.           => "The word `foo    ' actually has 3 letters in it."
  726.  
  727.    After any minimum field width, a precision may be specified by
  728. preceding it with a `.' character.  The precision specifies the minimum
  729. number of digits to appear in `%d', `%i', `%o', `%x', and `%X'
  730. conversions (the number is padded on the left with zeroes as
  731. necessary); the number of digits printed after the decimal point for
  732. `%f', `%e', and `%E' conversions; the number of significant digits
  733. printed in `%g' and `%G' conversions; and the maximum number of
  734. non-padding characters printed in `%s' and `%S' conversions.  The
  735. default precision for floating-point conversions is six.
  736.  
  737.    The other flag characters have the following meanings:
  738.  
  739.    * The ` ' flag means prefix non-negative numbers with a space.
  740.  
  741.    * The `+' flag means prefix non-negative numbers with a plus sign.
  742.  
  743.    * The `#' flag means print numbers in an alternate, more verbose
  744.      format: octal numbers begin with zero; hex numbers begin with a
  745.      `0x' or `0X'; a decimal point is printed in `%f', `%e', and `%E'
  746.      conversions even if no numbers are printed after it; and trailing
  747.      zeroes are not omitted in `%g' and `%G' conversions.
  748.  
  749. 
  750. File: lispref.info,  Node: Character Case,  Next: Case Tables,  Prev: Formatting Strings,  Up: Strings and Characters
  751.  
  752. Character Case
  753. ==============
  754.  
  755.    The character case functions change the case of single characters or
  756. of the contents of strings.  The functions convert only alphabetic
  757. characters (the letters `A' through `Z' and `a' through `z'); other
  758. characters are not altered.  The functions do not modify the strings
  759. that are passed to them as arguments.
  760.  
  761.    The examples below use the characters `X' and `x' which have ASCII
  762. codes 88 and 120 respectively.
  763.  
  764.  - Function: downcase STRING-OR-CHAR
  765.      This function converts a character or a string to lower case.
  766.  
  767.      When the argument to `downcase' is a string, the function creates
  768.      and returns a new string in which each letter in the argument that
  769.      is upper case is converted to lower case.  When the argument to
  770.      `downcase' is a character, `downcase' returns the corresponding
  771.      lower case character. (This value is actually an integer under
  772.      XEmacs 19.) If the original character is lower case, or is not a
  773.      letter, then the value equals the original character.
  774.  
  775.           (downcase "The cat in the hat")
  776.                => "the cat in the hat"
  777.           
  778.           (downcase ?X)
  779.                => ?x   ;; Under XEmacs 20.
  780.                => 120  ;; Under XEmacs 19.
  781.  
  782.  - Function: upcase STRING-OR-CHAR
  783.      This function converts a character or a string to upper case.
  784.  
  785.      When the argument to `upcase' is a string, the function creates
  786.      and returns a new string in which each letter in the argument that
  787.      is lower case is converted to upper case.
  788.  
  789.      When the argument to `upcase' is a character, `upcase' returns the
  790.      corresponding upper case character. (This value is actually an
  791.      integer under XEmacs 19.)  If the original character is upper
  792.      case, or is not a letter, then the value equals the original
  793.      character.
  794.  
  795.           (upcase "The cat in the hat")
  796.                => "THE CAT IN THE HAT"
  797.           
  798.           (upcase ?x)
  799.                => ?X   ;; Under XEmacs 20.
  800.                => 88   ;; Under XEmacs 19.
  801.  
  802.  - Function: capitalize STRING-OR-CHAR
  803.      This function capitalizes strings or characters.  If
  804.      STRING-OR-CHAR is a string, the function creates and returns a new
  805.      string, whose contents are a copy of STRING-OR-CHAR in which each
  806.      word has been capitalized.  This means that the first character of
  807.      each word is converted to upper case, and the rest are converted
  808.      to lower case.
  809.  
  810.      The definition of a word is any sequence of consecutive characters
  811.      that are assigned to the word constituent syntax class in the
  812.      current syntax table (*Note Syntax Class Table::).
  813.  
  814.      When the argument to `capitalize' is a character, `capitalize' has
  815.      the same result as `upcase'.
  816.  
  817.           (capitalize "The cat in the hat")
  818.                => "The Cat In The Hat"
  819.           
  820.           (capitalize "THE 77TH-HATTED CAT")
  821.                => "The 77th-Hatted Cat"
  822.           
  823.           (capitalize ?x)
  824.                => ?X   ;; Under XEmacs 20.
  825.                => 88   ;; Under XEmacs 19.
  826.  
  827. 
  828. File: lispref.info,  Node: Case Tables,  Next: Char Tables,  Prev: Character Case,  Up: Strings and Characters
  829.  
  830. The Case Table
  831. ==============
  832.  
  833.    You can customize case conversion by installing a special "case
  834. table".  A case table specifies the mapping between upper case and lower
  835. case letters.  It affects both the string and character case conversion
  836. functions (see the previous section) and those that apply to text in the
  837. buffer (*note Case Changes::.).  You need a case table if you are using
  838. a language which has letters other than the standard ASCII letters.
  839.  
  840.    A case table is a list of this form:
  841.  
  842.      (DOWNCASE UPCASE CANONICALIZE EQUIVALENCES)
  843.  
  844. where each element is either `nil' or a string of length 256.  The
  845. element DOWNCASE says how to map each character to its lower-case
  846. equivalent.  The element UPCASE maps each character to its upper-case
  847. equivalent.  If lower and upper case characters are in one-to-one
  848. correspondence, use `nil' for UPCASE; then XEmacs deduces the upcase
  849. table from DOWNCASE.
  850.  
  851.    For some languages, upper and lower case letters are not in
  852. one-to-one correspondence.  There may be two different lower case
  853. letters with the same upper case equivalent.  In these cases, you need
  854. to specify the maps for both directions.
  855.  
  856.    The element CANONICALIZE maps each character to a canonical
  857. equivalent; any two characters that are related by case-conversion have
  858. the same canonical equivalent character.
  859.  
  860.    The element EQUIVALENCES is a map that cyclicly permutes each
  861. equivalence class (of characters with the same canonical equivalent).
  862. (For ordinary ASCII, this would map `a' into `A' and `A' into `a', and
  863. likewise for each set of equivalent characters.)
  864.  
  865.    When you construct a case table, you can provide `nil' for
  866. CANONICALIZE; then Emacs fills in this string from UPCASE and DOWNCASE.
  867. You can also provide `nil' for EQUIVALENCES; then Emacs fills in this
  868. string from CANONICALIZE.  In a case table that is actually in use,
  869. those components are non-`nil'.  Do not try to specify EQUIVALENCES
  870. without also specifying CANONICALIZE.
  871.  
  872.    Each buffer has a case table.  XEmacs also has a "standard case
  873. table" which is copied into each buffer when you create the buffer.
  874. Changing the standard case table doesn't affect any existing buffers.
  875.  
  876.    Here are the functions for working with case tables:
  877.  
  878.  - Function: case-table-p OBJECT
  879.      This predicate returns non-`nil' if OBJECT is a valid case table.
  880.  
  881.  - Function: set-standard-case-table TABLE
  882.      This function makes TABLE the standard case table, so that it will
  883.      apply to any buffers created subsequently.
  884.  
  885.  - Function: standard-case-table
  886.      This returns the standard case table.
  887.  
  888.  - Function: current-case-table
  889.      This function returns the current buffer's case table.
  890.  
  891.  - Function: set-case-table TABLE
  892.      This sets the current buffer's case table to TABLE.
  893.  
  894.    The following three functions are convenient subroutines for packages
  895. that define non-ASCII character sets.  They modify a string
  896. DOWNCASE-TABLE provided as an argument; this should be a string to be
  897. used as the DOWNCASE part of a case table.  They also modify the
  898. standard syntax table.  *Note Syntax Tables::.
  899.  
  900.  - Function: set-case-syntax-pair UC LC DOWNCASE-TABLE
  901.      This function specifies a pair of corresponding letters, one upper
  902.      case and one lower case.
  903.  
  904.  - Function: set-case-syntax-delims L R DOWNCASE-TABLE
  905.      This function makes characters L and R a matching pair of
  906.      case-invariant delimiters.
  907.  
  908.  - Function: set-case-syntax CHAR SYNTAX DOWNCASE-TABLE
  909.      This function makes CHAR case-invariant, with syntax SYNTAX.
  910.  
  911.  - Command: describe-buffer-case-table
  912.      This command displays a description of the contents of the current
  913.      buffer's case table.
  914.  
  915.    You can load the library `iso-syntax' to set up the standard syntax
  916. table and define a case table for the 8-bit ISO Latin 1 character set.
  917.  
  918. 
  919. File: lispref.info,  Node: Char Tables,  Prev: Case Tables,  Up: Strings and Characters
  920.  
  921. The Char Table
  922. ==============
  923.  
  924.    A char table is a table that maps characters (or ranges of
  925. characters) to values.  Char tables are specialized for characters,
  926. only allowing particular sorts of ranges to be assigned values.
  927. Although this loses in generality, it makes for extremely fast
  928. (constant-time) lookups, and thus is feasible for applications that do
  929. an extremely large number of lookups (e.g. scanning a buffer for a
  930. character in a particular syntax, where a lookup in the syntax table
  931. must occur once per character).
  932.  
  933.    Note that char tables as a primitive type, and all of the functions
  934. in this section, exist only in XEmacs 20.  In XEmacs 19, char tables are
  935. generally implemented using a vector of 256 elements.
  936.  
  937.    When MULE support exists, the types of ranges that can be assigned
  938. values are
  939.  
  940.    * all characters
  941.  
  942.    * an entire charset
  943.  
  944.    * a single row in a two-octet charset
  945.  
  946.    * a single character
  947.  
  948.    When MULE support is not present, the types of ranges that can be
  949. assigned values are
  950.  
  951.    * all characters
  952.  
  953.    * a single character
  954.  
  955.  - Function: char-table-p OBJECT
  956.      This function returns non-`nil' if OBJECT is a char table.
  957.  
  958. * Menu:
  959.  
  960. * Char Table Types::            Char tables have different uses.
  961. * Working With Char Tables::    Creating and working with char tables.
  962.  
  963. 
  964. File: lispref.info,  Node: Char Table Types,  Next: Working With Char Tables,  Up: Char Tables
  965.  
  966. Char Table Types
  967. ----------------
  968.  
  969.    Each char table type is used for a different purpose and allows
  970. different sorts of values.  The different char table types are
  971.  
  972. `category'
  973.      Used for category tables, which specify the regexp categories that
  974.      a character is in.  The valid values are `nil' or a bit vector of
  975.      95 elements.  Higher-level Lisp functions are provided for working
  976.      with category tables.  Currently categories and category tables
  977.      only exist when MULE support is present.
  978.  
  979. `char'
  980.      A generalized char table, for mapping from one character to
  981.      another.  Used for case tables, syntax matching tables,
  982.      `keyboard-translate-table', etc.  The valid values are characters.
  983.  
  984. `generic'
  985.      An even more generalized char table, for mapping from a character
  986.      to anything.
  987.  
  988. `display'
  989.      Used for display tables, which specify how a particular character
  990.      is to appear when displayed.  #### Not yet implemented.
  991.  
  992. `syntax'
  993.      Used for syntax tables, which specify the syntax of a particular
  994.      character.  Higher-level Lisp functions are provided for working
  995.      with syntax tables.  The valid values are integers.
  996.  
  997.  - Function: char-table-type TABLE
  998.      This function returns the type of char table TABLE.
  999.  
  1000.  - Function: char-table-type-list
  1001.      This function returns a list of the recognized char table types.
  1002.  
  1003.  - Function: valid-char-table-type-p TYPE
  1004.      This function returns `t' if TYPE if a recognized char table type.
  1005.  
  1006. 
  1007. File: lispref.info,  Node: Working With Char Tables,  Prev: Char Table Types,  Up: Char Tables
  1008.  
  1009. Working With Char Tables
  1010. ------------------------
  1011.  
  1012.  - Function: make-char-table TYPE
  1013.      This function makes a new, empty char table of type TYPE.  TYPE
  1014.      should be a symbol, one of `char', `category', `display',
  1015.      `generic', or `syntax'.
  1016.  
  1017.  - Function: put-char-table RANGE VAL TABLE
  1018.      This function sets the value for chars in RANGE to be VAL in TABLE.
  1019.  
  1020.      RANGE specifies one or more characters to be affected and should be
  1021.      one of the following:
  1022.  
  1023.         * `t' (all characters are affected)
  1024.  
  1025.         * A charset (only allowed when MULE support is present)
  1026.  
  1027.         * A vector of two elements: a two-octet charset and a row number
  1028.           (only allowed when MULE support is present)
  1029.  
  1030.         * A single character
  1031.  
  1032.      VAL must be a value appropriate for the type of TABLE.
  1033.  
  1034.  - Function: get-char-table CH TABLE
  1035.      This function finds the value for char CH in TABLE.
  1036.  
  1037.  - Function: get-range-char-table RANGE TABLE &optional MULTI
  1038.      This function finds the value for a range in TABLE.  If there is
  1039.      more than one value, MULTI is returned (defaults to `nil').
  1040.  
  1041.  - Function: reset-char-table TABLE
  1042.      This function resets a char table to its default state.
  1043.  
  1044.  - Function: map-char-table FUNCTION TABLE &optional RANGE
  1045.      This function maps FUNCTION over entries in TABLE, calling it with
  1046.      two args, each key and value in the table.
  1047.  
  1048.      RANGE specifies a subrange to map over and is in the same format
  1049.      as the RANGE argument to `put-range-table'.  If omitted or `t', it
  1050.      defaults to the entire table.
  1051.  
  1052.  - Function: valid-char-table-value-p VALUE CHAR-TABLE-TYPE
  1053.      This function returns non-`nil' if VALUE is a valid value for
  1054.      CHAR-TABLE-TYPE.
  1055.  
  1056.  - Function: check-valid-char-table-value VALUE CHAR-TABLE-TYPE
  1057.      This function signals an error if VALUE is not a valid value for
  1058.      CHAR-TABLE-TYPE.
  1059.  
  1060. 
  1061. File: lispref.info,  Node: Lists,  Next: Sequences Arrays Vectors,  Prev: Strings and Characters,  Up: Top
  1062.  
  1063. Lists
  1064. *****
  1065.  
  1066.    A "list" represents a sequence of zero or more elements (which may
  1067. be any Lisp objects).  The important difference between lists and
  1068. vectors is that two or more lists can share part of their structure; in
  1069. addition, you can insert or delete elements in a list without copying
  1070. the whole list.
  1071.  
  1072. * Menu:
  1073.  
  1074. * Cons Cells::              How lists are made out of cons cells.
  1075. * Lists as Boxes::          Graphical notation to explain lists.
  1076. * List-related Predicates:: Is this object a list?  Comparing two lists.
  1077. * List Elements::           Extracting the pieces of a list.
  1078. * Building Lists::          Creating list structure.
  1079. * Modifying Lists::         Storing new pieces into an existing list.
  1080. * Sets And Lists::          A list can represent a finite mathematical set.
  1081. * Association Lists::       A list can represent a finite relation or mapping.
  1082. * Property Lists::          A different way to represent a finite mapping.
  1083. * Weak Lists::              A list with special garbage-collection behavior.
  1084.  
  1085. 
  1086. File: lispref.info,  Node: Cons Cells,  Next: Lists as Boxes,  Up: Lists
  1087.  
  1088. Lists and Cons Cells
  1089. ====================
  1090.  
  1091.    Lists in Lisp are not a primitive data type; they are built up from
  1092. "cons cells".  A cons cell is a data object that represents an ordered
  1093. pair.  It records two Lisp objects, one labeled as the CAR, and the
  1094. other labeled as the CDR.  These names are traditional; see *Note Cons
  1095. Cell Type::.  CDR is pronounced "could-er."
  1096.  
  1097.    A list is a series of cons cells chained together, one cons cell per
  1098. element of the list.  By convention, the CARs of the cons cells are the
  1099. elements of the list, and the CDRs are used to chain the list: the CDR
  1100. of each cons cell is the following cons cell.  The CDR of the last cons
  1101. cell is `nil'.  This asymmetry between the CAR and the CDR is entirely
  1102. a matter of convention; at the level of cons cells, the CAR and CDR
  1103. slots have the same characteristics.
  1104.  
  1105.    Because most cons cells are used as part of lists, the phrase "list
  1106. structure" has come to mean any structure made out of cons cells.
  1107.  
  1108.    The symbol `nil' is considered a list as well as a symbol; it is the
  1109. list with no elements.  For convenience, the symbol `nil' is considered
  1110. to have `nil' as its CDR (and also as its CAR).
  1111.  
  1112.    The CDR of any nonempty list L is a list containing all the elements
  1113. of L except the first.
  1114.  
  1115. 
  1116. File: lispref.info,  Node: Lists as Boxes,  Next: List-related Predicates,  Prev: Cons Cells,  Up: Lists
  1117.  
  1118. Lists as Linked Pairs of Boxes
  1119. ==============================
  1120.  
  1121.    A cons cell can be illustrated as a pair of boxes.  The first box
  1122. represents the CAR and the second box represents the CDR.  Here is an
  1123. illustration of the two-element list, `(tulip lily)', made from two
  1124. cons cells:
  1125.  
  1126.       ---------------         ---------------
  1127.      | car   | cdr   |       | car   | cdr   |
  1128.      | tulip |   o---------->| lily  |  nil  |
  1129.      |       |       |       |       |       |
  1130.       ---------------         ---------------
  1131.  
  1132.    Each pair of boxes represents a cons cell.  Each box "refers to",
  1133. "points to" or "contains" a Lisp object.  (These terms are synonymous.)
  1134. The first box, which is the CAR of the first cons cell, contains the
  1135. symbol `tulip'.  The arrow from the CDR of the first cons cell to the
  1136. second cons cell indicates that the CDR of the first cons cell points
  1137. to the second cons cell.
  1138.  
  1139.    The same list can be illustrated in a different sort of box notation
  1140. like this:
  1141.  
  1142.          ___ ___      ___ ___
  1143.         |___|___|--> |___|___|--> nil
  1144.           |            |
  1145.           |            |
  1146.            --> tulip    --> lily
  1147.  
  1148.    Here is a more complex illustration, showing the three-element list,
  1149. `((pine needles) oak maple)', the first element of which is a
  1150. two-element list:
  1151.  
  1152.          ___ ___      ___ ___      ___ ___
  1153.         |___|___|--> |___|___|--> |___|___|--> nil
  1154.           |            |            |
  1155.           |            |            |
  1156.           |             --> oak      --> maple
  1157.           |
  1158.           |     ___ ___      ___ ___
  1159.            --> |___|___|--> |___|___|--> nil
  1160.                  |            |
  1161.                  |            |
  1162.                   --> pine     --> needles
  1163.  
  1164.    The same list represented in the first box notation looks like this:
  1165.  
  1166.       --------------       --------------       --------------
  1167.      | car   | cdr  |     | car   | cdr  |     | car   | cdr  |
  1168.      |   o   |   o------->| oak   |   o------->| maple |  nil |
  1169.      |   |   |      |     |       |      |     |       |      |
  1170.       -- | ---------       --------------       --------------
  1171.          |
  1172.          |
  1173.          |        --------------       ----------------
  1174.          |       | car   | cdr  |     | car     | cdr  |
  1175.           ------>| pine  |   o------->| needles |  nil |
  1176.                  |       |      |     |         |      |
  1177.                   --------------       ----------------
  1178.  
  1179.    *Note Cons Cell Type::, for the read and print syntax of cons cells
  1180. and lists, and for more "box and arrow" illustrations of lists.
  1181.  
  1182. 
  1183. File: lispref.info,  Node: List-related Predicates,  Next: List Elements,  Prev: Lists as Boxes,  Up: Lists
  1184.  
  1185. Predicates on Lists
  1186. ===================
  1187.  
  1188.    The following predicates test whether a Lisp object is an atom, is a
  1189. cons cell or is a list, or whether it is the distinguished object
  1190. `nil'.  (Many of these predicates can be defined in terms of the
  1191. others, but they are used so often that it is worth having all of them.)
  1192.  
  1193.  - Function: consp OBJECT
  1194.      This function returns `t' if OBJECT is a cons cell, `nil'
  1195.      otherwise.  `nil' is not a cons cell, although it *is* a list.
  1196.  
  1197.  - Function: atom OBJECT
  1198.      This function returns `t' if OBJECT is an atom, `nil' otherwise.
  1199.      All objects except cons cells are atoms.  The symbol `nil' is an
  1200.      atom and is also a list; it is the only Lisp object that is both.
  1201.  
  1202.           (atom OBJECT) == (not (consp OBJECT))
  1203.  
  1204.  - Function: listp OBJECT
  1205.      This function returns `t' if OBJECT is a cons cell or `nil'.
  1206.      Otherwise, it returns `nil'.
  1207.  
  1208.           (listp '(1))
  1209.                => t
  1210.           (listp '())
  1211.                => t
  1212.  
  1213.  - Function: nlistp OBJECT
  1214.      This function is the opposite of `listp': it returns `t' if OBJECT
  1215.      is not a list.  Otherwise, it returns `nil'.
  1216.  
  1217.           (listp OBJECT) == (not (nlistp OBJECT))
  1218.  
  1219.  - Function: null OBJECT
  1220.      This function returns `t' if OBJECT is `nil', and returns `nil'
  1221.      otherwise.  This function is identical to `not', but as a matter
  1222.      of clarity we use `null' when OBJECT is considered a list and
  1223.      `not' when it is considered a truth value (see `not' in *Note
  1224.      Combining Conditions::).
  1225.  
  1226.           (null '(1))
  1227.                => nil
  1228.           (null '())
  1229.                => t
  1230.  
  1231.